package com.zynn.service.module.calculate.junit;


/**
 * @author liqi
 *
 * 1.可见性
 *
 * 2.不保证原子性
 *
 *
 */
public class VolatileDemo {


    private int number;


    public void addTo60(){
        number = 60;
    }

    public VolatileDemo(){
        System.out.println("构造方法");
    }

    public VolatileDemo(int number){
        this.number = number;
    }

    /**
     * 重写toString的方法
     * @return
     */
    @Override
    public String toString() {
        return "VolatileDemo{" +
                "number=" + number +
                '}';
    }
}

class Test{


    public static void main(String[] args) {
        System.out.println("volatile is use");

        VolatileDemo demo = new VolatileDemo(10);

        demo.addTo60();

        System.out.println(demo.toString());




    }
}
